package com.hns.can.service.web;

import com.hns.can.common.web.BaseController;
import com.hns.can.service.entity.BaseDrvChkParamInfoEntity;
import com.hns.can.service.service.DriverTotalScoreService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.math.BigDecimal;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * 考核权重设置Controller
 * @author:zhangzq
 * @email:
 * @version Revision 2.0.0
 */
@Controller
@RequestMapping("/driverTotalScore")
public class DriverTotalScoreController extends BaseController {

    @Autowired
    private DriverTotalScoreService driverTotalScoreService;

    /**
     * 驾驶员总评分设置 - 获取该组织机构下的驾驶员总评分设置信息，如果没有的话显示为默认的信息
     * @param corpId
     * @param organId
     * @author:zhangzq
     * @email:
     */
    @RequestMapping("/searchDriverTotalScoreInfo")
    @ResponseBody
    public Object searchDriverTotalScoreInfo(String corpId, String organId) throws Exception {
        Map<String, Object> paraMap = new HashMap<String, Object>();
        paraMap.put("organId", organId);
        paraMap.put("corpId", corpId);
        paraMap.put("qchkCgyCodes", new String[]{"CHK01000"});
        List<BaseDrvChkParamInfoEntity> list = driverTotalScoreService.searchDriverTotalScoreInfo(paraMap);
        return this.getReturnResult(list);
    }

    /**
     * 新建或更新驾驶员总评分设置
     * @param seleDrvOrganId
     * @param currDrvOrganId
     * @param corpId
     * @author:zhangzq
     * @email:
     */
    @RequestMapping("/uptDriverTotalScoreInfo")
    @ResponseBody
    public Object uptDriverTotalScoreInfo(String seleDrvOrganId, String currDrvOrganId, String[] chkIds,BigDecimal[] weightValues,String corpId) throws Exception {
        driverTotalScoreService.uptDriverTotalScoreInfo(seleDrvOrganId, currDrvOrganId, chkIds, weightValues, corpId);
        return this.getReturnMsg("您成功修改该机构的驾驶员考核权重参数。");
    }

}
